<template>
  <div>
    <input type="text" v-show="flag" ref="fouce" />
    <button @click="isshow" v-show="!flag">点击搜索</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      flag: false,
    }
  },
  methods: {
    isshow() {
      this.flag = !this.flag
      // setTimeout(() => this.$refs.fouce.focus(), 0)
      this.$nextTick(() => this.$refs.fouce.focus())
    },
  },
}
</script>

<style></style>
